$(function(){
	//关闭待办弹出框
	$(".portal-dialog-close-btn").click(function(e){
		var postMessage = {};
		postMessage.type = "closeDialog";
		window.parent.postMessage(JSON.stringify(postMessage), '*');
	});

	//收藏功能
    $(".nav-webfinal > li > a").click(function (e) {
        //记录当前点击的链接，供收藏使用
        var menu = $(this);
        var postMessage = {};
        postMessage.type = "clickMenu";
        postMessage.content = {
            menuPath: menu.attr("ref"),
            menuName: menu.attr("menu"),
            menuIcon: menu.attr("icon"),
            appCoe:""

        };
        window.parent.postMessage(JSON.stringify(postMessage), '*');
    });

    //处理点击菜单消息
    function dealMessage(e){
        var postMessage = JSON.parse(e.data);
        if (postMessage.type == "storeClick") {
            $('.nav-webfinal> li > a[ref="' + postMessage.menuURl + '"]').click()
        }
    }

    if(window.addEventListener) {
        window.addEventListener('message', dealMessage, false); //chrome,firefox
    }else{
        window.attachEvent('onmessage', dealMessage); //ie
    }



    window.parent.postMessage(JSON.stringify({type: "storeJump"}), '*');
});